Skip to content

Client: relaunch MasterTech while RemoteExec is armed - #366

Merged
shadowbrok3r merged 1 commit into
mainfrom
feat/mastertech-watchdog
Oct 10, 2026
Merged

shadowbrok3r merged 1 commit into
mainfrom
feat/mastertech-watchdog

Conversation

@shadowbrok3r

Copy link
Copy Markdown
Owner

Summary

While RemoteExec is armed, MasterTech now comes back by itself when it dies or Windows restarts, so an overnight remote job doesn't stall until someone walks over to the machine.

  • Arming RemoteExec registers a MastertechWatchdog scheduled task for the logged-on user, at the highest run level. It has two triggers:
    • a logon trigger;
    • a trigger that repeats every 5 minutes.
  • Both triggers expire one hour after the lease ends, and the expired task deletes itself.
  • The task starts MasterTech.exe --watchdog. A --watchdog launch exits at once when the Local\MasterTech.Instance mutex shows an instance is already running. Every GUI and terminal instance opens that mutex at startup; --mcp-stdio does not.
  • These remove the task:
    • disarming RemoteExec;
    • closing MasterTech normally.
  • A close while Windows is shutting down keeps the task (SM_SHUTTINGDOWN), so MasterTech returns after a reboot that MasterTech didn't start itself.
  • The existing one-shot reboot relaunch (MastertechAutoRestart) now passes --watchdog too, so the two tasks never start a second copy.
  • Task settings:
    • IgnoreNew, so a running copy the task started blocks repeat launches;
    • no execution time limit (the default 72 h limit would end a long-running MasterTech);
    • starts when available, and runs on battery.
  • The remote_exec_arm tool description now tells agents that the relaunched client comes back disarmed and needs a re-arm.
  • MTECH_NO_WATCHDOG=1 skips registration.

Why

A QC machine's MasterTech died mid-install overnight. Nothing could relaunch it until a technician came in, so the rest of the QC sat idle for the night. Webroot kills (see the vssadmin rule) end the session the same way.

Testing

  • Unit tests for the generated PowerShell:
    • flag and terminal-mode arguments;
    • expiry and self-delete;
    • no time limit, IgnoreNew, highest run level;
    • quote escaping and the minimum window;
    • --watchdog parsing.
  • Probes on Windows 11 26200 with throwaway tasks, through PowerShell 5.1 the way MasterTech runs it:
    • the generated script registers;
    • EndBoundary keeps its UTC offset, DeleteExpiredTaskAfter is PT0S and ExecutionTimeLimit is PT0S;
    • a second start under IgnoreNew starts no new instance;
    • re-registering with -Force and deleting with schtasks /delete both leave the running instance alive.
  • cargo clippy -p MasterTech --no-deps --bin MasterTech --tests: nothing new.

Clients need a release to pick this up.

🤖 Generated with Claude Code

Arming RemoteExec registers a MastertechWatchdog scheduled task (logon
plus a 5-minute repeat, both expiring an hour after the lease) that starts
MasterTech with --watchdog. A --watchdog launch exits at once when the
Local\MasterTech.Instance mutex shows an instance is running. Disarming or
a normal close deletes the task; a close during Windows shutdown keeps it.
The reboot relaunch task passes --watchdog too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shadowbrok3r
shadowbrok3r merged commit 5941c00 into main Oct 10, 2026
10 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant